package android.academy.haixue.com.haixue;

import android.academy.haixue.com.haixue.utils.Consts;
import android.os.Environment;
import android.support.multidex.MultiDexApplication;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

import cn.woblog.android.common.skin.core.ThemeManager;
import cn.woblog.android.common.utils.FileUitls;
import de.mindpipe.android.logging.log4j.LogConfigurator;

/**
 * Created by ren on 2015/5/4 0004.
 */
public class MyApplication extends MultiDexApplication{

    private Logger log;

    @Override
    public void onCreate() {super.onCreate();
        initLog();
        initDir();
        init();
        ThemeManager.setContext(getApplicationContext());

    }

    private void init() {
//        Stetho.initialize(
//                Stetho.newInitializerBuilder(this)
//                        .enableDumpapp(Stetho.defaultDumperPluginsProvider(this))
//                        .enableWebKitInspector(Stetho.defaultInspectorModulesProvider(this))
//                        .build());
    }

    private void initDir() {
        log.info("init dir");
        FileUitls.makeDir(Consts.ROOT_BASE_DIR);
    }

    //initialization log4j
    private void initLog() {
        final LogConfigurator logConfigurator = new LogConfigurator();
        logConfigurator.setFileName(Environment.getExternalStorageDirectory()
                + Consts.Log_FIlENAME);
        logConfigurator.setRootLevel(Level.DEBUG);
        logConfigurator.setLevel("org.apache", Level.ERROR);
        logConfigurator.setMaxFileSize(1000 * 10);
        logConfigurator.setUseLogCatAppender(true);
        logConfigurator.configure();

        log = Logger.getLogger(MyApplication.class);
        log.info("init log");
    }
}
